/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package casino;

import java.util.Iterator;

/**
 * Class that is the game manager for roulette.
 * 
 * @author amaghfur
 */
public class RouletteGame extends Game {
    
    public int  straightBetOdds = 35,
                splitBetOdds = 17,
                streetBetOdds = 11,
                cornerBetOdds = 8,
                lineBetOdds = 5,
                dozenBetOdds = 2,
                columnBetOdds = 2,
                evenMoneyBetOdds = 1,
                fiverBetOdds = 6;
    
    /** wheel used */
    private Wheel wheel;
    /** table used */
    private Table table;
    
    /**
     * Class constructor for a roulette game using the specified wheel and table.
     * 
     * @param wheelUsed wheel used
     * @param tableUsed table used
     */
    public RouletteGame(Wheel wheelUsed, Table tableUsed) {
        super();
        wheel = wheelUsed;
        table = tableUsed;
    }
    
    /** getter for wheel */
    public Wheel getWheel() {
        return wheel;
    }
    
    /**
     * Executes a single cycle of play with the given player.
     * 
     */
    @Override
    public void cycle(Player player) {
        player.placeBets();
        Bin winningBin = wheel.next();
        player.winners(winningBin.getOutcomes()); // Notify player of the winning outcomes.
        // Iterate through all bets on the table to determine and handle winners/losers.
        Iterator<Bet> itBets = table.iterator();
        while(itBets.hasNext()) {
            Bet currentBet = itBets.next();
            if (winningBin.getOutcomes().contains(currentBet.getOutcome()) == true)
                player.win(currentBet);
            else
                player.lose(currentBet);
            itBets.remove(); // remove bet from table
        }
    }
}
